#define DEBUG
#include <cstdio>

using namespace std;

class ChairmanTree {
public:
  int l, r, v;
  ChairmanTree *left, *right;

  ChairmanTree(int l, int r) {
    this->l = l, this->r = r;
  }

  void add(ChairmanTree *o, int t, int tv) {
    if (l==r) {
      if (o) {
	v = o->v+tv;
      } else {
	v = tv;
      }
    } else {
      int mid=(l+r)/2;
      if (t<=mid) {
	left = new ChairmanTree(1, mid);
	if (o) {
	  right = o->right;
	  left->add(o->left, t, tv);
	  v = o->right->v+o->left->v;
	} else {
	  left->add(NULL, t, tv);
	  v = o->left->v;
	}
      } else {
	right = new ChairmanTree(mid+1, r);
	if (o) {
	  left = o->left;
	  right->add(o->right, t, tv);
	  v = o->right->v+o->left->v;
	} else {
	  right->add(NULL, t, tv);
	  v = o->right->v;
	}
      }
    }
  }

  int getKth(int k) {
    if (l==r) {
      return l;
    } else if (left && left->v>=k) {
      return left->getKth(k);
    } else {
      return right->getKth(k-left->v);
    }
  }
};

int main() {
#ifdef DEBUG
  freopen("2.in", "r", stdin);
  freopen("2.out", "w", stdout);
#endif

  ChairmanTree *

  fclose(stdin);
  fclose(stdout);
  return 0;
}
